# -*- coding: utf-8 -*-
# Created by methew at 2018/6/2
from functools import wraps
from flask_restful import Resource
from flask_security import auth_token_required, roles_required, roles_accepted


def authenticate(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)
    return wrapper


class BaseResource(Resource):
    method_decorators = [auth_token_required, roles_required('admin')]


class UserResource(Resource):
    method_decorators = [roles_accepted(
        'admin', 'user'), auth_token_required]


class CounsellorResource(Resource):
    method_decorators = [roles_accepted(
        'admin', 'counsellor'), auth_token_required]


class CommonResource(Resource):
    method_decorators = [roles_accepted(
        'admin', 'counsellor', 'user'), auth_token_required]


class OpenResource(Resource):
    pass
